home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: in1.uu.net!shore!mv!usenet
- From: ENGR@GSSI.MV.COM (Michael Furman)
- Subject: Re: Help: very simple(?) array problem
- Message-ID: <DpnHMA.IMy@mv.mv.com>
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- Organization: GSSI
- Date: Wed, 10 Apr 1996 14:30:09 GMT
- References: <4kejrv$ml2@kruuna.helsinki.fi>
- X-Newsreader: WinVN 0.99.7
- X-Nntp-Posting-Host: gssi.mv.com
-
- In article <4kejrv$ml2@kruuna.helsinki.fi>, marjakan@cc.helsinki.fi says...
- >
- >I have tried to get a piece of code to work for couple of hours now and
- >I don't know any longer what is wrong with it. All seems OK with me, but
- >still compiler (both GNU-C++ and C++) give an error:
- >"initializer for scalar variable requires one element".
- >I'm totally confused.
- >
- >The code looks following...
- >
- >class Object
- >{
- >...
- > Object(char **name);
- >...
- >};
- >
- >Object::Object(char **name)
- >{
- > ...
- >}
- >
- >main()
- >{
- > char **b={"First","Second"};
- > Object a(b);
- >}
- >
- >If I change main() to
- >{
- > Object a({"First","Second"});
- >}
- >
- >both compilers report "parse error before {" at that line which
- >contains Object a(...);
- >
- >I simply cannot understand what can be wrong, to me it looks just fine.
- >Can anyone help?
-
- The best way to - take a book and look at it. And compiler message could
- help. Look at ARM 8.4.1 - initializers like yours may be used only in
- aggregate arrays. And you tried to apply it to pointer or class - that is
- incorrect.
-
- The closest think you can do is:
-
- char * b[] = {"first", "second"};
-
-
- --
- <<< If you received it by E-mail: it is a copy of post to the newsgroup >>>
- ---------------------------------------------------------------
- Michael Furman, (603)893-1109
- Geophysical Survey Systems, Inc. fax:(603)889-3984
- 13 Klein Drive - P.O. Box 97 engr@gssi.mv.com
- North Salem, NH 03073-0097 71543.1334@compuserve.com
- ---------------------------------------------------------------
-
-